//
//  StatusCellBottomView.swift
//  Weibo
//
//  Created by 李亚乐 on 15/12/11.
//  Copyright © 2015年 李亚乐. All rights reserved.
//

import UIKit

// MARK: - 底部视图
class StatusCellBottomView: UIView {

    /// 构造方法
    ///
    /// - returns: 底部视图
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //MARK: - 懒加载控件
    /// 转发按钮
    private lazy var retweetedButton: UIButton = UIButton(imageName: "timeline_icon_retweet", title: " 转发", fontSize: 12, titleColor: UIColor.darkGrayColor())
    /// 评论按钮
    private lazy var commentButton: UIButton = UIButton(imageName: "timeline_icon_comment", title: " 评论", fontSize: 12, titleColor: UIColor.darkGrayColor())
    /// 点赞按钮
    private lazy var likeButton: UIButton = UIButton(imageName: "timeline_icon_unlike", title: " 赞", fontSize: 12, titleColor: UIColor.darkGrayColor())
    
}

// MARK: - 设置 UI
extension StatusCellBottomView {
    private func setupUI() {
        backgroundColor = UIColor.whiteColor()
        
        //添加子控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        //设置自动布局
/// 转发按钮
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
/// 评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.width.equalTo(retweetedButton.snp_width)
            make.height.equalTo(retweetedButton.snp_height)
        }
/// 点赞按钮
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(commentButton.snp_top)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        
 /// 分隔视图
        let sepV1 = sepView()
        let sepV2 = sepView()
        addSubview(sepV1)
        addSubview(sepV2)
        
        // 布局
        let w = 1
        let scale = 0.4
        
        sepV1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
        sepV2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.width.equalTo(sepV1)
            make.height.equalTo(sepV1)
        }
        
    }

    /// 创建分隔视图
    ///
    /// - returns: 分隔视图
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.lightGrayColor()
        return v
    }

}



